<template>
	<view class="in_list" :style="alertWidth">
		<navitop>
			<i class="iconfont icon-jiantou-copy" slot="left-slot" @click="outlot"></i>
			<span slot="center-slot">商机添加</span>
			<!-- <i class="iconfont icon-youcecaidan" slot="right-slot"  @click="laert(data)"></i> -->
		</navitop>
		<div :style="'margin-top:' + nv_height">
			<div style="background-color: #f0f0f0;" class="public_mag_top"></div>
			<scroll-view class="staff_b" scroll-y="true" touch-action=none; >
				<div class="public_list_style">
					<div class="public_list_out">
						<div>
							<div id="public_lists" v-for="(rows,ind) in dataSorce" v-if="rows.onEdit">
								<div class="public_list_left_one">
									<text style="color: red;" v-if="rows.onFill">*</text>
									<text>{{rows.name}}: </text>
								</div>
								<div class="public_list_right" v-if="rows.type == '搜索选择'">
									<typeinput :type="rows.type" :values="vity_lists" :value="rows.value" :code="rows.code"  @user_alert="user_alert" ></typeinput>
								</div>
								<div class="public_list_right" v-else>
									<typeinput :type="rows.type" :values="rows.val" :value="rows.value" :code="rows.code"  @user_alert="user_alert" ></typeinput>
								</div>
							
							</div>
						</div>
					</div>
					<div class="list_tree">
						<setp :options="list" direction="column" :active="activety" @NuberList="NuberList"></setp>
					</div>
				</div>
				<div ></div><br>
				<div class="public_button" >
					<div class="public_text" @click="okclick">
						保&nbsp;&nbsp;存
					</div>
				</div>
			</scroll-view>
		</div>
	</view>
</template>
<script>
import typeinput from '@/pages/common/common/public_input/type_input'
import navitop from '@/components/common/navi-top'
import setp from '@/uni_modules/uni-steps/components/uni-steps/uni-steps'
import {listCompanyActivities,businesssave,list,pages} from '@/common/api/job/jobapi.js'
export default {
	components: {
		setp,
		navitop,
		typeinput
	},
	props:{
		dsorce: {
			default: ''
		},
		user_id: {
			default: ''
		},
		rmtype: {
			default: ''
		},
		url: {
			default: ''
		}
	},
	data(){
		return {
			list:[],
			activety: 0,
			vity_lists: '',
			dataSorce: [],
			rundata: {},
			nv_height: '',
			alertWidth:''
		}
	},
	mounted() {
		const res = uni.getSystemInfoSync();
		this.nv_height = uni.getSystemInfoSync().statusBarHeight + 55 + 'px';
		
		this.http_lsit();
		this.vity_list();
		
		console.log('rul--------',this.url)
	},
	methods: {
		outlot(){
			// this.$emit('inbusaddclose',2)
		},
		// 获取详情
		http_lsit(id,type){
			let arrrun = [];
			list({source:'business'}).then((row)=>{
				if(row.code ==200){
					this.dataSorce = row.data
				}
			})
		},
		user_alert(val){
			this.dataSorce.forEach(item=>{
				if(item.code == val.code){
					this.$set(item,'value',val.value)
				}
			})
			if(val.code == 'activityId'){
				this.rundata[val.code] = val.id;
			}else {
				this.rundata[val.code] = val.value;
			}
		
		},
		// 活动列表
		vity_list(){
			listCompanyActivities().then((row) => {
				if(row.code == 200){
					this.vity_lists = row.data
					console.log(this.vity_lists)
				}
			})
		},
		okclick(){	
			for(let i in this.dataSorce){
				if(this.dataSorce[i].code !== "goingStatus" && this.dataSorce[i].code !== "projectNo" && this.dataSorce[i].code !== "crmName"){
					if(this.dataSorce[i].onAppFill){
						if(this.dataSorce[i].value == undefined || this.dataSorce[i].value == ''){
							uni.showToast({
								title: '请输入' + this.dataSorce[i].name,
								icon: 'error'
							})
							return false;
						}
					}
				}
			}
			this.rundata['chargeManId'] = this.dsorce['collarUserId'];
			this.rundata['chargeManName'] = this.dsorce['collarUserName'];
			this.rundata['crmId'] = this.dsorce['id'];
			this.rundata['crmName'] = this.dsorce['crmName'];
			businesssave(this.rundata).then((rows)=> {
				if(rows.code == 200){
					uni.showToast({
						title: '保存成功'
					});
					setTimeout(()=>{
						uni.navigateTo({
						    url: '/pages/common/index/detial?id=' + this.dsorce['id'] + this.url
						});
					},1500)
				}
			})
		}
		
	}
}	
	
	
</script>

<style scoped lang="scss">
	
.in_list {
	width: 100%;
	background-color: #fff;
}

#public_lists {
	display: flex;
	height: 90rpx;
	line-height: 90rpx;
	padding: 0 0 0 30rpx;
	
}
	
</style>
